package com.demo.entity;

import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class MyLog {
	
	private Logger logger=Logger.getLogger(MyTransaction.class);
	
	@Before("execution(* com.demo.dao.impl.*.*(..))")
	public void beforeLogger(){
		System.out.println("do someThing");
	}
	
	@AfterReturning(pointcut="execution(* com.demo.dao.impl.*.*(..))")
	public void afterLogger(){
		System.out.println("afterLogger  do someThing");
	}
	
	@Around("execution(* com.demo.dao.impl.*.*(..))")
	public Object aroundLogger(ProceedingJoinPoint joinPoint){
		Object result=null;
		try {
			result = joinPoint.proceed();
			return result;
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	   
			   
		System.out.println("aroundLogger  do someThing");
		return result;
	}

}
